﻿using AdminSystem.Application.Commands.lmgCommands;
using AdminSystem.Application.Dtos;
using AdminSystem.EntityFramworkCore;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AdminSystem.WebAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ImageController : ControllerBase
    {
        private readonly IMediator mediator;
        public ImageController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<APIResult<object>> AddImages(lmgAddCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 删除图片
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> DelImage(string Id)
        {
            lmgDelCommand command = new lmgDelCommand();
            command.Id = Id;
            return await mediator.Send(command);
        }
        [HttpGet]
        public async Task<APIResult<List<ImgDto>>> GetImage(int Id)
        {
            lmgQueryCommand command = new lmgQueryCommand();
            command.TheRestId = Id;
            return await mediator.Send(command);
        }
    }
}
